#!/usr/bin/env python
import gtk
import pygtk
pygtk.require('2.0')
class numpad:
    """
    Simple numpad
    NumPad.show() shows the Numpad
    """
    def __init__(self):
    #create a 4x3 homogeneos table to pack in the numbers
        self.table=gtk.Table(4,3,True)
    
    #create a tuple of buttons
        self.buttons=(gtk.Button("0"),
                      gtk.Button("1"),
                      gtk.Button("2"),
                      gtk.Button("3"),
                      gtk.Button("4"),
                      gtk.Button("5"),
                      gtk.Button("6"),
                      gtk.Button("7"),
                      gtk.Button("8"),
                      gtk.Button("9"))
#now attach each button in the right spot on table
        self.table.attach(self.buttons[0],1,2,3,4)
        self.table.attach(self.buttons[1],0,1,2,3)
        self.table.attach(self.buttons[2],1,2,2,3)
        self.table.attach(self.buttons[3],2,3,2,3)
        self.table.attach(self.buttons[4],0,1,1,2)
        self.table.attach(self.buttons[5],1,2,1,2)
        self.table.attach(self.buttons[6],2,3,1,2)
        self.table.attach(self.buttons[7],0,1,0,1)
        self.table.attach(self.buttons[8],1,2,0,1)
        self.table.attach(self.buttons[9],2,3,0,1)
        
         
    #make an interface to connect each button to a function
    def button_connect(self,ButtonNum,event,call_back_function,Data=None):
        self.buttons[ButtonNum].connect(event,call_back_function,Data)

    def show(self):
        for b in self.buttons:
            b.show()
        self.table.show()
    
    def add(self):
        """use to pack into the gui"""
        return self.table

if __name__ == "__main__":
    np=numpad()
    win=gtk.Window(gtk.WINDOW_TOPLEVEL)
    win.connect("destroy",gtk.main_quit)
    win.show()
    win.add(np.add())
    np.show()
    gtk.main()
else:
    print "imported Numpad"

    
